<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://www.ecside.org" prefix="ec"%>
<jsp:useBean id="pageBean" scope="request"
	class="com.agileai.hotweb.domain.PageBean" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Web服务分组管理</title>
<%@include file="/jsp/inc/resource.inc.jsp"%>
<script language="javascript">
	function doRefresh(nodeId) {
		$('#GRP_ID').val(nodeId);
		doSubmit({
			actionType : 'refresh'
		});
	}
	var targetTreeBox;
	function showParentSelectBox() {
		if (!targetTreeBox) {
			targetTreeBox = new PopupBox('targetTreeBox', '请选择目标目录', {
				size : 'normal',
				width : '300px',
				top : '3px'
			});
		}
		var handlerId = "WsResGroupParentSelect";
		var url = 'index?' + handlerId + '&GRP_ID=' + $("#GRP_ID").val();
		targetTreeBox.sendRequest(url);
	}
	function doChangeParent() {
		postRequest('form1', {
			actionType : 'changeParent',
			onComplete : function(responseText) {
				if (responseText == 'success') {
					doRefresh($('#GRP_ID').val());
				} else {
					alert('迁移父节点出错啦！');
				}
			}
		});
	}
	function doSave() {
		if (checkSave()) {
			$("#operaType").val('update');
			doSubmit({
				actionType : 'save'
			});
		}
	}
	function checkSave() {
		var result = true;
		if (validation.checkNull($('#GRP_NAME').val())) {
			writeErrorMsg($("#GRP_NAME").attr("label") + "不能为空!");
			selectOrFocus('GRP_NAME');
			return false;
		}
		if ($('#GRP_NAME').val().length > 64) {
			writeErrorMsg($("#GRP_NAME").attr("label") + "长度不能大于" + 64 + "!");
			selectOrFocus('GRP_NAME');
			return false;
		}
		return result;
	}
	function doMoveUp() {
		doSubmit({
			actionType : 'moveUp'
		});
	}
	function doMoveDown() {
		doSubmit({
			actionType : 'moveDown'
		});
	}
	function doCopyCurrent() {
		doSubmit({
			actionType : 'copyCurrent'
		});
	}
	function doDelete() {
		if (confirm('确定要进行节点删除操做吗？')) {
			doSubmit({
				actionType : 'delete'
			});
		}
	}
	function doInsertChild() {
		if (checkInsertChild()) {
			$("#operaType").val('insert');
			doSubmit({
				actionType : 'insertChild'
			});
		}
	}
	function checkInsertChild() {
		var result = true;
		if (validation.checkNull($('#CHILD_GRP_NAME').val())) {
			writeErrorMsg($("#CHILD_GRP_NAME").attr("label") + "不能为空!");
			selectOrFocus('CHILD_GRP_NAME');
			return false;
		}
		if ($('#CHILD_GRP_NAME').val().length > 64) {
			writeErrorMsg($("#CHILD_GRP_NAME").attr("label") + "长度不能大于" + 64
					+ "!");
			selectOrFocus('CHILD_GRP_NAME');
			return false;
		}
		return result;
	}
	function doCancel() {
		doRefresh($('#GRP_ID').val());
	}
</script>
</head>
<body>
	<form action="<%=pageBean.getHandlerURL()%>" name="form1" id="form1"
		method="post">
		<%@include file="/jsp/inc/message.inc.jsp"%>
		<table width="100%" style="margin: 0px;">
			<tr>
				<td valign="top">
					<div id="leftTree" class="sharp color2" style="margin-top: 0px;">
						<b class="b1"></b><b class="b2"></b><b class="b3"></b><b
							class="b4"></b>
						<div class="content">
							<div id="treeArea"
								style="overflow: auto; height: 420px; width: 230px; background-color: #F9F9F9; padding-top: 5px; padding-left: 5px;">
								<%=pageBean.getStringValue("menuTreeSyntax")%></div>
							<b class="b9"></b>
							</div>
					</div>
				</td>
				<td width="85%" valign="top">
					<fieldset id="currentArea" style="padding: 0 5px 5px 5px;">
						<legend style="font-weight: bolder;">编辑当前节点</legend>
						<div id="__ToolBar__" style="margin-top: 2px">
							<table border="0" cellpadding="0" cellspacing="1">
								<tr>
									<td
										<%if (!pageBean.getBoolValue("isRootNode")
					&& !pageBean.inputValue("GRP_EDITABLE").equals("N")) {%>
										onmouseover="onMover(this);" onmouseout="onMout(this);"
										onclick="doSave()" <%}%> class="bartdx" hotKey="E"
										align="center"><input id="saveImgBtn" value="&nbsp;"
										title="保存" type="button" class="saveImgBtn"
										style="margin-right: 0px;" />保存</td>
									<td <%if (!pageBean.getBoolValue("isRootNode")
					&& !pageBean.inputValue("GRP_EDITABLE").equals("N")) {%>
										onmouseover="onMover(this);" onmouseout="onMout(this);"
										onclick="doDelete()" <%}%> class="bartdx" hotKey="D"
										align="center"><input id="delImgBtn" value="&nbsp;"
										title="删除" type="button" class="delImgBtn"
										style="margin-right: 0px;" />删除</td>
									<td <%if (!pageBean.getBoolValue("isRootNode")
					&& !pageBean.inputValue("GRP_EDITABLE").equals("N")) {%>
										onmouseover="onMover(this);" onmouseout="onMout(this);"
										onclick="doCopyCurrent()" <%}%> class="bartdx" align="center"><input
										id="copyImgBtn" value="&nbsp;" title="复制" type="button"
										class="copyImgBtn" style="margin-right: 0px;" />复制</td>
									<td <%if (!pageBean.getBoolValue("isRootNode")
					&& !pageBean.inputValue("GRP_EDITABLE").equals("N")) {%>
										onmouseover="onMover(this);" onmouseout="onMout(this);"
										onclick="showParentSelectBox()" <%}%> class="bartdx"
										align="center"><input id="moveImgBtn" value="&nbsp;"
										title="迁移" type="button" class="moveImgBtn"
										style="margin-right: 0px;" />迁移</td>
									<td <%if (!pageBean.getBoolValue("isRootNode")
					&& !pageBean.inputValue("GRP_EDITABLE").equals("N")) {%>
										onmouseover="onMover(this);" onmouseout="onMout(this);"
										onclick="doMoveUp()" <%}%> class="bartdx" align="center"><input
										id="upImgBtn" value="&nbsp;" title="上移" type="button"
										class="upImgBtn" style="margin-right: 0px;" />上移</td>
									<td <%if (!pageBean.getBoolValue("isRootNode")
					&& !pageBean.inputValue("GRP_EDITABLE").equals("N")) {%>
										onmouseover="onMover(this);" onmouseout="onMout(this);"
										onclick="doMoveDown()" <%}%> class="bartdx" align="center"><input
										id="downImgBtn" value="&nbsp;" title="下移" type="button"
										class="downImgBtn" style="margin-right: 0px;" />下移</td>
								</tr>
							</table>
						</div>
						<table class="detailTable" cellspacing="0" cellpadding="0">
							<tr>
								<th width="100" nowrap>分组名称</th>
								<td><input id="GRP_NAME" label="分组名称" name="GRP_NAME"
									type="text" value="<%=pageBean.inputValue("GRP_NAME")%>"
									size="32" class="text" /></td>
							</tr>
							<tr>
								<th width="100" nowrap>服务类型</th>
								<td>
									<input id="CODE_NAME" label="服务类型" name="CODE_NAME" class="text" value="<%=pageBean.inputValue("CODE_NAME")%>" readonly="readonly"/>
									<input type="hidden" name="GRP_TYPE" id="GRP_TYPE" value="<%=pageBean.inputValue("GRP_TYPE")%>" />
								</td>
							<tr>
								<th width="100" nowrap>分组描述</th>
								<td><textarea id="GRP_DESC" label="分组描述" name="GRP_DESC"
										cols="40" rows="3" class="textarea"><%=pageBean.inputValue("GRP_DESC")%></textarea>
								</td>
							</tr>
						</table>
					</fieldset>

					<fieldset id="childArea" style="margin-top: 10px; padding: 5px;">
						<legend style="font-weight: bolder;">添加子节点</legend>
						<div id="__ToolBar__">
							<table border="0" cellpadding="0" cellspacing="1">
								<tr>
									<td <%if (!pageBean.getBoolValue("isRootNode")) {%> onmouseover="onMover(this);" onmouseout="onMout(this);"
										onclick="doInsertChild()"<%}%> class="bartdx" align="center" ><input
										value="&nbsp;" title="新增" type="button" id="createImgBtn" class="createImgBtn"
										style="margin-right: 0px;" />新增</td>
									<td <%if (!pageBean.getBoolValue("isRootNode")) {%> onmouseover="onMover(this);" onmouseout="onMout(this);"
										onclick="doCancel()"<%}%> class="bartdx" align="center" ><input
										value="&nbsp;" title="取消" type="button" id="cancelImgBtn" class="cancelImgBtn"
										style="margin-right: 0px;" />取消</td>
								</tr>
							</table>
						</div>
						<table class="detailTable" cellspacing="0" cellpadding="0">
							<tr>
								<th width="100" nowrap>分组名称</th>
								<td><input id="CHILD_GRP_NAME" label="分组名称"
									name="CHILD_GRP_NAME" type="text"
									value="<%=pageBean.inputValue("CHILD_GRP_NAME")%>" size="32"
									class="text" /></td>
							</tr>
							<tr>
								<th width="100" nowrap>服务类型</th>
								<td>
									<input id="CHILD_CODE_NAME" label="服务类型" name="CHILD_CODE_NAME" class="text" value="<%=pageBean.inputValue("CODE_NAME")%>" readonly="readonly"/>
									<input type="hidden" name="CHILD_GRP_TYPE" id="CHILD_GRP_TYPE" value="<%=pageBean.inputValue("GRP_TYPE")%>" />
								</td>
							</tr>
							<tr>
								<th width="100" nowrap>分组描述</th>
								<td><textarea id="CHILD_GRP_DESC" label="分组描述"
										name="CHILD_GRP_DESC" cols="40" rows="3" class="textarea"><%=pageBean.inputValue("CHILD_GRP_DESC")%></textarea>
								</td>
							</tr>
						</table>
					</fieldset>
				</td>
			</tr>
		</table>
		<input type="hidden" name="actionType" id="actionType" value="" /> 
		<input type="hidden" name="operaType" id="operaType" value="" /> 
		<input type="hidden" id="GRP_ID" name="GRP_ID" value="<%=pageBean.inputValue("GRP_ID")%>" /> 
		<input type="hidden" id="GRP_FID" name="GRP_FID" value="<%=pageBean.inputValue("GRP_FID")%>" /> 
		<input type="hidden" id="GRP_SORT" name="GRP_SORT" value="<%=pageBean.inputValue("GRP_SORT")%>" />
		<input type="hidden" id="TABLE_NAME" name="TABLE_NAME" value="ws_res_group" />
	</form>
</body>
</html>
<script language="javascript">
<%if (pageBean.getBoolValue("isRootNode")
					|| pageBean.inputValue("GRP_EDITABLE").equals("N")) {%>
	setImgDisabled('saveImgBtn',true);
	setImgDisabled('delImgBtn',true);
	setImgDisabled('copyImgBtn',true);
	setImgDisabled('moveImgBtn',true);
	setImgDisabled('upImgBtn',true);
	setImgDisabled('downImgBtn',true);
<%}%>
<%if (pageBean.getBoolValue("isRootNode")) {%>
	setImgDisabled('createImgBtn',true);
	setImgDisabled('cancelImgBtn',true);
<%}%>
$(function(){
	resetTreeHeight(80);
	var areaHeight = $("#leftTree").height()/2;
	$("#currentArea").height(areaHeight-2);
	$("#childArea").height(areaHeight-2);
});
</script>
<%@include file="/jsp/inc/scripts.inc.jsp"%>
<script language="javascript">
</script>
